package com.keyancompany.zhongbaopingtai.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;

import com.keyancompany.zhongbaopingtai.ConstansUrl;
import com.keyancompany.zhongbaopingtai.Constants;
import com.keyancompany.zhongbaopingtai.R;
import com.keyancompany.zhongbaopingtai.adapter.IFragmentPagerAdapter;
import com.keyancompany.zhongbaopingtai.fragment.TaskFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.BindString;

/**
 * 团队任务
 */
public class TeamTaskActivity extends BaseActivity {

    @BindString(R.string.team_task)
    String title;
    @Bind(R.id.toolbar)
    Toolbar toolbar;
    @Bind(R.id.tabLayout)
    TabLayout tabLayout;
    @Bind(R.id.complaint_viewpager)
    ViewPager complaintViewpager;

    @Override
    protected int getContentViewId() {
        return R.layout.layout_tab_viewpager;
    }

    @Override
    protected int getMenuId() {
        return 0;
    }

    @Override
    protected void initToolBar() {
        initToolBar(toolbar, title);
    }

    @Override
    protected void setUpViews() {
        String teamCode = getIntent().getStringExtra(Constants.TEAM_CODE);
        tabLayout.addTab(tabLayout.newTab());
        tabLayout.addTab(tabLayout.newTab());
        tabLayout.addTab(tabLayout.newTab());
        tabLayout.addTab(tabLayout.newTab());
        List<Fragment> tcf = new ArrayList<>();

        tcf.add(TaskFragment.newInstance(0, teamCode));
        tcf.add(TaskFragment.newInstance(1, teamCode));
        tcf.add(TaskFragment.newInstance(2, teamCode));
        tcf.add(TaskFragment.newInstance(3, teamCode));


        final IFragmentPagerAdapter pagerAdapter = new IFragmentPagerAdapter(getSupportFragmentManager(), tcf);

        String tabTitles[] = mContext.getResources().getStringArray(R.array.task_state);

        pagerAdapter.setTitles(tabTitles);
        complaintViewpager.setAdapter(pagerAdapter);


        tabLayout.setupWithViewPager(complaintViewpager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
    }
}
